package org.vshe.improve.spring.prospring3.ch6;

import org.springframework.aop.Advisor;
import org.springframework.aop.aspectj.AspectJExpressionPointcut;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.aop.support.DefaultPointcutAdvisor;

public class AspectJExpPointcutText {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		BeanOne beanOne = new BeanOne();
		
		AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
		pointcut.setExpression("execution(* writeMessage*(..))");
		
		Advisor advisor = new DefaultPointcutAdvisor(pointcut, new SimpleAdvice());
		
		ProxyFactory factory = new ProxyFactory();
		factory.setTarget(beanOne);
		factory.addAdvisor(advisor);
		
		BeanOne proxyOne = (BeanOne) factory.getProxy();
		
		proxyOne.writeMessage();
	}

}
